package com.block.api.controller.merchant;


import com.alibaba.fastjson.JSONObject;
import com.block.common.bean.CommonParam;
import com.block.common.exception.ApiException;
import com.block.common.security.util.ApiUtil;
import com.block.common.vo.ResponseVo;
import com.block.db.entity.AppEncrypt;
import com.block.merchant.service.IMerchantProductLaunchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.Date;

@RestController
@RequestMapping("api/MerchantProductLaunch")
@Validated
public class MerchantProductLaunchController {

    @Autowired
    IMerchantProductLaunchService merchantProductLaunchService;

    @RequestMapping(value = "/getList", method = {RequestMethod.POST, RequestMethod.GET})
    public String getPageList(@RequestAttribute(value = "tranData") JSONObject tranData,
                              @RequestAttribute(value = "appEncrypt") AppEncrypt appEncrypt,
                              @RequestAttribute(value = "uri") String uri,
                              @RequestAttribute(value = "commonParam") CommonParam commonParam,
                              @RequestAttribute(value = "startDate") Date startdate,
                              @RequestAttribute(value = "ip") String ip) throws ApiException {

        ResponseVo responseVo = merchantProductLaunchService.getMerchantProductLaunchList();
        return ApiUtil.dealReturnJson(responseVo, appEncrypt, startdate, uri);
    }

    @RequestMapping(value = "/getOverList", method = {RequestMethod.POST,RequestMethod.GET})
    public String getOverList(@RequestAttribute(value = "tranData") JSONObject tranData,
                              @RequestAttribute(value = "appEncrypt") AppEncrypt appEncrypt,
                              @RequestAttribute(value = "uri") String uri,
                              @RequestAttribute(value = "commonParam") CommonParam commonParam,
                              @RequestAttribute(value = "startDate") Date startdate,
                              @RequestAttribute(value = "ip") String ip,
                              @RequestParam String listIds) throws ApiException {


        ResponseVo responseVo = merchantProductLaunchService.getOverList(listIds);
        return ApiUtil.dealReturnJson(responseVo, appEncrypt, startdate, uri);
    }
}
